<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>监听消息</button>
<div id="message"></div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
    $("button").click(function () {
        var source = new EventSource('http://localhost:8080/start/' + "1");

        source.addEventListener('message', function (e) {
            console.log(e.data);
            document.getElementById("message").innerHTML += e.data + '<br>';
        }, false);

        source.addEventListener('error', function (e) {
            console.log("异常：" + e.data)
        });
    });

</script>

</body>
</html>